#include <iostream>
using namespace std;

namespace VECTOR {
class Vector {
public:
  Vector();
  Vector(double n1, double n2, char from = 'r');
  void set(double n1, double n2, char from = 'r');
  ~Vector();
  double xval() const { return _x; };
  double yval() const { return _y; };
  double magval() const { return _mag; }
  double angval() const { return _ang; }
  void polar_mode();
  void rect_mode();

  Vector operator+(const Vector &b) const;
  Vector operator-(const Vector &b) const;
  Vector operator-() const;
  Vector operator*(double n) const;

  // friend
  friend Vector operator*(double n, const Vector &a);
  friend std::ostream &operator<<(std::ostream &os, const Vector &v);

private:
  double _x;
  double _y;
  double _mag;
  double _ang;
  char _mode;
  void set_mag();
  void set_ang();
  void set_x();
  void set_y();
};
} // namespace VECTOR
